<template>
  <Modal :mask-closable="false" class="modal-title-layout" v-model="show" :title="`${$t('回退')}`">
    <div class="icon red">
      <i class="iconfont zy-common-fanhui"></i>
    </div>
    <p class="title">
      <span>{{$t('回退到上一个节点')}}？</span>
    </p>
    <div slot="footer">
      <Button type="default" @click="show=false">{{ $t('common.Cancle') }}</Button>
      <Button :loading="btnLoading" type="primary" @click="submit">{{ $t('回退') }}
      </Button>
    </div>
  </Modal>
</template>

<script>
export default {
  name: "callbackModal",
  props:['id','active'],
  data() {
    return {
      show: false,
      index: "",
      btnLoading:false
    }
  },
  methods: {
    showModal() {
      this.show = true
    },
    submit() {
      this.btnLoading = true
      this.axios({
        method: 'post',
        url: '/dms/capex/approval',
        data: {
          approvalStatus:0,
          remark:this.$t('回退到上一个节点'),
          progressCode : this.active,
          id : this.id
        }
      }).then(res => {
        if (res.code === 200) {
          this.show = false
          this.$Message.success(res.msg)
          // location.reload()
          this.$router.go(-1)
        } else {
          this.$Message.warning(({content: res.msg, duration: 6, closable: true}));
        }
      }).finally(()=>{
        this.btnLoading = false
      })
    }
  }
}
</script>
